package com.vcs.frm.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "jobseekers")
public class Jobseeker {

	private Long jobseekerId;
	private String firstName;
	private String lastName;
	private String email;
	private int age;
	private Date birthDate;
	private Long phoneNumber;
	private City currentLocation;
	private Address address;
	
	private Date createdDate;
	private Date updatedDate;
	private Set<Job> jobs = new HashSet<Job>();
	
	private Resume resume;
	
	@Id
	// @GeneratedValue
	@Column(name = "JOBSEEKER_ID")
	public Long getJobseekerId() {
		return jobseekerId;
	}

	public void setJobseekerId(Long jobseekerId) {
		this.jobseekerId = jobseekerId;
	}

	@Column(name = "EMAIL")
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	
	@Column(name = "AGE")
	public int getAge() {
		return age;
	}
	
	public void setAge(int age) {
		this.age = age;
	}
	
	@Temporal(TemporalType.DATE)
	@Column(name = "BIRTH_DATE", nullable = true)
	public Date getBirthDate() {
		return birthDate;
	}
	
	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}
	
	
	@Column(name = "PHONE_NUMBER")
	public Long getPhoneNumber() {
		return phoneNumber;
	}
	
	public void setPhoneNumber(Long phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	
	@Column(name = "FIRST_NAME")
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	@Column(name = "LAST_NAME")
	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@ManyToMany(cascade = CascadeType.ALL, mappedBy = "jobseekers")
	public Set<Job> getJobs() {
		return jobs;
	}
	
	public void setJobs(Set<Job> jobs) {
		this.jobs = jobs;
	}

	@OneToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "CUR_LOCATION_ID", referencedColumnName = "CITY_ID")
	public City getCurrentLocation() {
		return currentLocation;
	}
	
	public void setCurrentLocation(City currentLocation) {
		this.currentLocation = currentLocation;
	}
	
	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "ADDRESS_ID")
	public Address getAddress() {
		return address;
	}
	
	public void setAddress(Address address) {
		this.address = address;
	}
	
	@Column(name = "CREATED_DATE" )
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreatedDate() {
		return createdDate;
	}
	
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	
	@Column(name = "UPDATED_DATE")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getUpdatedDate() {
		return updatedDate;
	}
	
	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}
	
	@OneToOne(mappedBy = "jobseeker", cascade = CascadeType.ALL)
	public Resume getResume() {
		return resume;
	}
	
	public void setResume(Resume resume) {
		this.resume = resume;
	}
	
}